﻿@model ArbabTravelsERP.Models.MENU

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Menu</h2>
@using (Html.BeginForm("Index", "Menu", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.AntiForgeryToken()
    <!-- page content -->
    <div class="right_col" role="main">
        <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>@ViewBag.SubTitle</h3>
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>@ViewBag.SubTitle</h2>
                            <div class="clearfix"></div>
                        </div>

                        <div class="x_content">

                            @if (ViewBag.Success != null)
                            {
                                <div class="alert alert-dismissable alert-success">
                                    <button type="button" class="close" data-dismiss="alert">×</button>
                                    @ViewBag.Success
                                </div>
                            }
                            else if (ViewBag.Error != null)
                            {
                                <div class="alert alert-dismissable alert-danger">
                                    <button type="button" class="close" data-dismiss="alert">×</button>
                                    @ViewBag.Error
                                </div>
                            }

                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>Menu Name</th>
                                        <th>Menu Title</th>
                                        <th>URL</th>
                                        <th>Is Parent</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    @for (int i = 0; i < Model.MenuDS.Tables[0].Rows.Count; i++)
                                    {
                                        <tr>
                                            <td>@Model.MenuDS.Tables[0].Rows[i]["MENU_NAME"].ToString()</td>
                                            <td>@Model.MenuDS.Tables[0].Rows[i]["MENU_TITLE"].ToString()</td>
                                            <td>@Model.MenuDS.Tables[0].Rows[i]["PAGE_URL"].ToString()</td>
                                            <td>@Model.MenuDS.Tables[0].Rows[i]["IS_PARENT"].ToString()</td>
                                            <td>
                                                @if (@Model.MenuDS.Tables[0].Rows[i]["IS_PARENT"].ToString() != "False")
                                                {
                                                    @Html.ActionLink("View", "Index", new { ID = Model.MenuDS.Tables[0].Rows[i]["MENU_ID"].ToString() })
                                                }
                                                else
                                                {
                                                    @Html.DisplayName("View");
                                                }

                                                | @Html.ActionLink("Edit", "Edit", new { ID = Model.MenuDS.Tables[0].Rows[i]["MENU_ID"].ToString() })
                                                | @Html.ActionLink("Delete", "Delete", new { ID = Model.MenuDS.Tables[0].Rows[i]["MENU_ID"].ToString() })
                                            </td>
                                        </tr>
                                    }

                                    @if (Model.MenuDS.Tables[0].Rows.Count == 0)
                                    {
                                        <tr>
                                            <td colspan="5">Sub Menu is not present</td>

                                        </tr>
                                    }

                                    <tr>
                                        <td>
                                            @Html.TextBoxFor(m => m.MENU_NAME, new { @class = "form-control", @placeholder = "Menu Name", @autocomplete = "off" })
                                            @Html.ValidationMessageFor(m => m.MENU_NAME, "", new { @class = "text-danger" })
                                        </td>
                                        <td>
                                            @Html.TextBoxFor(m => m.MENU_TITLE, new { @class = "form-control", @placeholder = "Menu Title", @autocomplete = "off" })
                                            @Html.ValidationMessageFor(m => m.MENU_TITLE, "", new { @class = "text-danger" })
                                        </td>
                                        <td>
                                            @Html.TextBoxFor(m => m.PAGE_NAME, new { @class = "form-control widthtx", @placeholder = "Page Name", @autocomplete = "off" })
                                            @Html.ValidationMessageFor(m => m.PAGE_NAME, "", new { @class = "text-danger" })
                                            @Html.TextBoxFor(m => m.CONTROLLER_NAME, new { @class = "form-control widthtx", @placeholder = "Controller", @autocomplete = "off" })
                                            @Html.ValidationMessageFor(m => m.CONTROLLER_NAME, "", new { @class = "text-danger" })


                                        </td>
                                        <td>
                                            @Html.DropDownListFor(m => m.IS_PARENT, ViewData["IS_PARENT"] as SelectList, "-- Select --", new { @class = "form-control", @disabled = "disabled" })

                                        </td>
                                        <td>@Html.TextBoxFor(m => m.REMARK, new { @class = "form-control", @placeholder = "Remark", @autocomplete = "off" })</td>
                                    </tr>
                                    <tr>
                                        <td colspan="5">
                                            <div class="col-sm-3 col-md-3">

                                                <button type="submit" id="btnSubmit" class="btn btn-primary" title="Submit" value="Submit">Submit</button>
                                                @*<button type="reset" id="btnReset" class="btn btn-primary" title="Reset" value="Cancel">Main List</button>*@
                                                <div class="btn btn-default">
                                                    @Html.ActionLink("Parent Menu", "Index", new { ID = "" })
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}